package com.jnshu.controller;

import com.jnshu.service.MessageService;
import com.jnshu.tools.resultUtils.ResultBean;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName UserMessageController
 * @Descrintion
 * @Author bd
 * @Date 2019/8/10 17:02
 * @Version 1.0
 **/
@RestController
@Log
public class UserMessageController {

    @Autowired(required = false)
    MessageService messageService;


    /**
     * 前台消息列表
     */
    @GetMapping("/message/ulist")
    public ResultBean uSelectMessage(@RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                     @RequestParam(value = "userId") long userId) {
        return messageService.uSelectMessage(pageSize, pageNum, userId);
    }

    /**
     * 前台消息详情
     */
    @GetMapping("/umessage")
    public ResultBean uSelectId(Long id, long userId) {
        log.info("controller层传入的参数id为" + id);
        return messageService.uSelectId(id, userId);
    }

    /*
     * 一键阅读
     **/
    @GetMapping("/umessage/read")
    public ResultBean selectRead(Long userId){
        log.info("controller层传入的参数userId为" + userId);
        return messageService.selectRead(userId);
    }
}
